package com.pacy.pacybaseproject.viewmodels;

import android.app.Application;
import android.os.Bundle;
import android.view.View;


import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.pacy.pacybaseproject.activitys.MsgDetailActivity;
import com.pacy.pacybaseproject.adapters.MsgListAdapter;
import com.pacy.pacybaseproject.adapters.ReceiveAdapter;
import com.pacy.pacybaseproject.beans.HomeMsgBean;
import com.pacy.pacybaseproject.beans.MsgListBean;
import com.pacy.pacybaseproject.utils.Constants;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.annotations.NonNull;
import me.goldze.mvvmhabit.base.BaseViewModel;

/**
 * @author PACY
 * @date 2024/2/29
 * description:
 */
public class MsgListViewModel extends BaseViewModel {
    public MsgListAdapter mAdapter;
    public MsgListViewModel(@NonNull Application application) {
        super(application);
    }

    @Override
    protected void init() {
        super.init();
        initAdapter();
    }

    public void initAdapter(){
        mAdapter=new MsgListAdapter();
        List<MsgListBean> data=new ArrayList<>();
        data.add(new MsgListBean(0,"关于市区公交8路优化调整的公告","2024-01-04"));
        data.add(new MsgListBean(1,"关于市区公交部分线路恢复原线路运行的公告","2023-12-08"));
        mAdapter.setNewInstance(data);
        mAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                Bundle bundle=new Bundle();
                bundle.putInt("position",position);
                bundle.putString("title",mAdapter.getData().get(position).getContent());
                bundle.putString("time",mAdapter.getData().get(position).getTime());
                startActivity(MsgDetailActivity.class,bundle);
            }
        });
    }


}
